package com.liming.payment.controller;

import com.liming.common.pojo.dto.payment.PaymentUpdateDTO;
import com.liming.common.pojo.dto.payment.PrepayDTO;
import com.liming.common.result.LMResult;
import com.liming.payment.service.PaymentMircoService;
import com.liming.service.wx.pojo.vo.PrepayVO;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author liming
 * @date 2025/4/8
 */
@RestController
@AllArgsConstructor
@RequestMapping("/service/payment")
public class PaymentMircoController {

    private final PaymentMircoService paymentMircoService;

    @GetMapping("wx_repay/{orderId}")
    public LMResult<PrepayVO> wxRepay(@PathVariable Long orderId) {
        return LMResult.success(paymentMircoService.wxRepay(orderId));
    }

    @PostMapping("wx_prepay")
    public LMResult<Boolean> wxPrepay(@RequestBody PrepayDTO prepayDTO) {
        return LMResult.success(paymentMircoService.wxPrepay(prepayDTO));
    }

    @PutMapping("updateByOrderId")
    public LMResult<Boolean> updateByOrderId(@RequestBody PaymentUpdateDTO paymentUpdateDTO) {
        return LMResult.success(paymentMircoService.updateByOrderId(paymentUpdateDTO));
    }

}
